-
Notifications
You must be signed in to change notification settings - Fork 335
Allow MSVC on non Windows platforms for cross compilation #1818
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
This allows MSVC to be used on Linux. I tested this with a setup using the msvc-wine project that provided wrapper scripts around the Wine compatibility layer to run the MSVC compiler on other platforms. By forcing an external toolset this forces vcpkg to use the default compiler or the CC/CXX environment flags, which with use of I was able to cross compile some projects from Linux to Windows/MSVC.
|
Can you provide instructions on how we can test this? |
Basically on my Linux install I followed the instructions from https://github.com/mstorsjo/msvc-wine, then added the |
|
Stupid question: Does removing: #if !defined(WIN32)
Checks::msg_exit_with_error(VCPKG_LINE_INFO, msgErrorVcvarsUnsupported, msg::triplet = prebuildinfo.triplet);
#elsefix it rather than adding this? (I'm sorry to be asking lots of questions about this; I'm just nervous about adding funny ifdefs for things I can't check) |
Sorry for the late reply, but no as far as I can tell it doesn't because it tries to find Visual Studio toolsets (it actually calls functions that are not even compiled outside of Windows) and on this setup there really isn't a proper Visual Studio toolset anyways.
Yeah no problem, if you decide that this is too funny of a setup / quirk to be supported and reject this PR that would also be understandable, not many people will try to use something like this anyways. |
No, I don't want to outright reject, I just want to make sure I understand since this isn't a configuration I understand. I'm also trying to "probe" because this specific change is "strange" (why should non-Windows but 'using vcvars' take the 'no vcvars' It looks like you actually want vcvars used here. In that case we should probably return a Toolset that claims to do this rather than just giving up and falling to external toolset / PATH? struct Toolset
{
Path visual_studio_root_path;
Path vcvarsall;
std::vector<std::string> vcvarsall_options;
ZStringView version;
std::string full_version;
std::vector<ToolsetArchOption> supported_architectures;
};Seems like we should be returning something with those values filled out for this setup rather than the dummy values that appear to fall back to PATH.... |
|
We also have other comments that are wrong after this change, such as: #if !defined(WIN32)
// pre_build_info.using_vcvars() should always be false on non-Win32 hosts.
// If it was true, we should have failed earlier while selecting a Toolset
(void)toolset;
Checks::unreachable(VCPKG_LINE_INFO);
#elsein |
|
I'm not sure filling out the toolset values it going to be possible as on my setup I just have |
This allows MSVC to be used on Linux. I tested this with a setup using the msvc-wine project that provided wrapper scripts around the Wine compatibility layer to run the MSVC compiler on other platforms. By forcing an external toolset this forces vcpkg to use the default compiler or the CC/CXX environment flags, which with use of I was able to cross compile some projects from Linux to Windows/MSVC.